<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        var n = 3;

        // 可以代替if语句连续判断二者相等时的情况 n == 1
        switch(n) {
            case 1:
                console.log('a');
                break; // 终止语句，不然如果n = 1 ，它会执行后面所有语句。
            case 2:
                console.log('b');
                break;
            case 3:
                console.log('c');
                break;
            case 'a':
                console.log('d');
            case true:
                console.log('e');
        }


    </script>

    <script>
        var date = window.prompt('input');
        switch(date) {
            case "monday":
                console.log('working');
                break;
            case "tuesday":
                console.log('working');
                break;
            case "wednesday":
            case "thursday":
            case "friday":
                 console.log('working');
                 break;
            case "周六":
            case "周日":
                console.log('relaxing');
                break;
            default:
                
        }
    </script>
</body>
</html>